//
//      Copyright Timothy Evans 2014 2015    timothy.evans@gsecraif.org
//
//      This file is part of gsecraif.
//
//      gsecraif is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 3 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// =====================================================================     
//
//! gsecraif - File split and re-combination programme
//
// =====================================================================
//
// Compile with g++

#include "config.h"                     // needed by autoconf tools

#include "gsecraif.h"

using namespace std;

// Some global variables that can be specified as a command line parameter,
// but otherwise should not change:
unsigned short int debuglevel=0;
    // This global variable sets the verbosity level
bool showhashes = false;                // Print hashes?

int main(int argc, char *argv[])
{
const string version = "Alpha 04"; // programme version
// ------------------------------------

// The maximum number of component files the programme can split in to
// is 255 - this is declared in the parse_args function.
//
// Variables changed with command line parameters
// or used to parse command line parameters:

char action = 's';                      // action to take, one of:
                                        // s split input file
                                        // c combine input files
                                        // u print usage information and exit
                                        // v print version information and exit
                                        // h print help information and exit
                                        
int numoffiles = 3;                     // How many files to split in to
                                        // (default 3)
unsigned short int rrotate = 3;         // Number of bits to rotate left
bool transpose = false;					// Flag to show if bit transposition

// other variables:
vector<string> compfilenames;           // array of 3 - 255 component file names

// call function to parse arguments passed to the programme:
parse_args(argc, argv, action, numoffiles, rrotate, transpose, compfilenames);

switch (action) {
    case 'u':
        cerr << "Invalid option" << "\n";
        cerr << "Use " << argv[0] << " --help" << "\n";
        break;
    case 'h':
        print_help(argv[0]);
        break;
    case 'v':
        cout << "Version " << version << "\n";
        break;   
    case 's':
        // call function to split: 
        split_input(numoffiles, rrotate, transpose, compfilenames);
        break;
    case 'c':
        // call function to combine:
        combine_files(numoffiles, rrotate, transpose, compfilenames);
        break;
    } // end switch (action..
}  // end of main

// =====================================================================
